package com.hj.config.security.token;

import org.springframework.security.authentication.AbstractAuthenticationToken;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.SpringSecurityCoreVersion;

import java.util.Collection;

/**
 * @Description 密码登录 token 配置
 * @author hj
 */
public class PwdLoginToken extends AbstractAuthenticationToken {

    private static final long serialVersionUID = SpringSecurityCoreVersion.SERIAL_VERSION_UID;

    private final Object principal;

    private final Object credentials;

    private final Object verifyCode;

    public PwdLoginToken(Object principal, Object credentials, Object verifyCode) {
        super(null);
        this.principal = principal;
        this.credentials = credentials;
        this.verifyCode = verifyCode;
    }

    public PwdLoginToken(Object principal, Object credentials, Object verifyCode, Collection<? extends GrantedAuthority> authorities) {
        super(authorities);
        this.principal = principal;
        this.credentials = credentials;
        this.verifyCode = verifyCode;
        super.setAuthenticated(true);
    }

    @Override
    public Object getCredentials() {
        return this.credentials;
    }

    @Override
    public Object getPrincipal() {
        return this.principal;
    }

    public Object getVerifyCode() {
        return this.verifyCode;
    }


}
